﻿using System;
using System.Collections;
using System.Collections.Generic;
using MMD4MecanimInternal.Bullet;
using UnityEngine;
using UnityEngine.Rendering;

// Token: 0x02000090 RID: 144
[ExecuteInEditMode]
public class MMD4MecanimModel : MonoBehaviour, MMD4MecanimAnim.IAnimModel
{
	// Token: 0x06000323 RID: 803 RVA: 0x0001967D File Offset: 0x0001787D
	MMD4MecanimAnim.IMorph MMD4MecanimAnim.IAnimModel.GetMorph(string name)
	{
		return this.GetMorph(name);
	}

	// Token: 0x06000324 RID: 804 RVA: 0x00019686 File Offset: 0x00017886
	MMD4MecanimAnim.IMorph MMD4MecanimAnim.IAnimModel.GetMorph(string name, bool startsWith)
	{
		return this.GetMorph(name, startsWith);
	}

	// Token: 0x1700006E RID: 110
	// (get) Token: 0x06000325 RID: 805 RVA: 0x00019690 File Offset: 0x00017890
	int MMD4MecanimAnim.IAnimModel.morphCount
	{
		get
		{
			if (this.morphList != null)
			{
				return this.morphList.Length;
			}
			return 0;
		}
	}

	// Token: 0x06000326 RID: 806 RVA: 0x000196A7 File Offset: 0x000178A7
	MMD4MecanimAnim.IMorph MMD4MecanimAnim.IAnimModel.GetMorphAt(int index)
	{
		if (this.morphList != null && index >= 0 && index < this.morphList.Length)
		{
			return this.morphList[index];
		}
		return null;
	}

	// Token: 0x1700006F RID: 111
	// (get) Token: 0x06000327 RID: 807 RVA: 0x000196D3 File Offset: 0x000178D3
	int MMD4MecanimAnim.IAnimModel.animCount
	{
		get
		{
			if (this.animList != null)
			{
				return this.animList.Length;
			}
			return 0;
		}
	}

	// Token: 0x06000328 RID: 808 RVA: 0x000196EA File Offset: 0x000178EA
	MMD4MecanimAnim.IAnim MMD4MecanimAnim.IAnimModel.GetAnimAt(int index)
	{
		if (this.animList != null && index >= 0 && index < this.animList.Length)
		{
			return this.animList[index];
		}
		return null;
	}

	// Token: 0x17000070 RID: 112
	// (get) Token: 0x06000329 RID: 809 RVA: 0x00019716 File Offset: 0x00017916
	Animator MMD4MecanimAnim.IAnimModel.animator
	{
		get
		{
			return this._animator;
		}
	}

	// Token: 0x17000071 RID: 113
	// (get) Token: 0x0600032A RID: 810 RVA: 0x0001971E File Offset: 0x0001791E
	AudioSource MMD4MecanimAnim.IAnimModel.audioSource
	{
		get
		{
			if (this.audioSource == null)
			{
				this.audioSource = MMD4MecanimCommon.WeakAddComponent<AudioSource>(base.gameObject);
			}
			return this.audioSource;
		}
	}

	// Token: 0x17000072 RID: 114
	// (get) Token: 0x0600032B RID: 811 RVA: 0x00019748 File Offset: 0x00017948
	bool MMD4MecanimAnim.IAnimModel.animSyncToAudio
	{
		get
		{
			return this.animSyncToAudio;
		}
	}

	// Token: 0x17000073 RID: 115
	// (get) Token: 0x0600032C RID: 812 RVA: 0x00019750 File Offset: 0x00017950
	// (set) Token: 0x0600032D RID: 813 RVA: 0x00019758 File Offset: 0x00017958
	float MMD4MecanimAnim.IAnimModel.prevDeltaTime
	{
		get
		{
			return this._prevDeltaTime;
		}
		set
		{
			this._prevDeltaTime = value;
		}
	}

	// Token: 0x17000074 RID: 116
	// (get) Token: 0x0600032E RID: 814 RVA: 0x00019761 File Offset: 0x00017961
	// (set) Token: 0x0600032F RID: 815 RVA: 0x00019769 File Offset: 0x00017969
	MMD4MecanimAnim.IAnim MMD4MecanimAnim.IAnimModel.playingAnim
	{
		get
		{
			return this._playingAnim;
		}
		set
		{
			this._playingAnim = (MMD4MecanimModel.Anim)value;
		}
	}

	// Token: 0x06000330 RID: 816 RVA: 0x00019777 File Offset: 0x00017977
	void MMD4MecanimAnim.IAnimModel._SetAnimMorphWeight(MMD4MecanimAnim.IMorph morph, float weight)
	{
		((MMD4MecanimModel.Morph)morph)._animWeight = weight;
	}

	// Token: 0x06000331 RID: 817 RVA: 0x00019788 File Offset: 0x00017988
	private void _InitializeAnimatoion()
	{
		this._animator = base.GetComponent<Animator>();
		if (Application.isPlaying && this.animEnabled && this.animDelayedAwakeFrame > 0 && this._animator != null && this._animator.enabled)
		{
			this._animator.speed = 0f;
			this._isDelayedAwake = true;
		}
		this._animMorphCategoryWeights = new float[5];
		if (!Application.isPlaying)
		{
			return;
		}
		MMD4MecanimAnim.InitializeAnimModel(this);
	}

	// Token: 0x06000332 RID: 818 RVA: 0x00019818 File Offset: 0x00017A18
	private void _UpdateAnim()
	{
		if (!Application.isPlaying)
		{
			return;
		}
		if (this._bulletPhysicsMMDModel == null)
		{
			return;
		}
		if (this._isDelayedAwake)
		{
			if (this.animEnabled && this.animDelayedAwakeFrame > 0 && ++this._delayedAwakeFrame <= this.animDelayedAwakeFrame)
			{
				return;
			}
			this._isDelayedAwake = false;
			this._animator.speed = 1f;
		}
		MMD4MecanimAnim.PreUpdateAnimModel(this);
		if (!this.animEnabled)
		{
			MMD4MecanimAnim.StopAnimModel(this);
		}
		else
		{
			MMD4MecanimAnim.UpdateAnimModel(this);
		}
		MMD4MecanimAnim.PostUpdateAnimModel(this);
	}

	// Token: 0x06000333 RID: 819 RVA: 0x000198BC File Offset: 0x00017ABC
	private void _BindBone()
	{
		Transform transform = base.gameObject.transform;
		IEnumerator enumerator = transform.GetEnumerator();
		try
		{
			while (enumerator.MoveNext())
			{
				object obj = enumerator.Current;
				Transform trn = (Transform)obj;
				this._BindBone(trn);
			}
		}
		finally
		{
			IDisposable disposable;
			if ((disposable = (enumerator as IDisposable)) != null)
			{
				disposable.Dispose();
			}
		}
	}

	// Token: 0x06000334 RID: 820 RVA: 0x00019928 File Offset: 0x00017B28
	private void _BindBone(Transform trn)
	{
		if (!string.IsNullOrEmpty(trn.gameObject.name))
		{
			int num = 0;
			if (this._modelData.boneDataDictionary.TryGetValue(trn.gameObject.name, out num))
			{
				MMD4MecanimBone mmd4MecanimBone = trn.gameObject.GetComponent<MMD4MecanimBone>();
				if (mmd4MecanimBone == null)
				{
					mmd4MecanimBone = trn.gameObject.AddComponent<MMD4MecanimBone>();
				}
				mmd4MecanimBone.model = this;
				mmd4MecanimBone.boneID = num;
				mmd4MecanimBone.Setup();
				this.boneList[num] = mmd4MecanimBone;
				if (this.boneList[num].boneData != null && this.boneList[num].boneData.isRootBone)
				{
					this._rootBone = this.boneList[num];
				}
			}
		}
		IEnumerator enumerator = trn.GetEnumerator();
		try
		{
			while (enumerator.MoveNext())
			{
				object obj = enumerator.Current;
				Transform trn2 = (Transform)obj;
				this._BindBone(trn2);
			}
		}
		finally
		{
			IDisposable disposable;
			if ((disposable = (enumerator as IDisposable)) != null)
			{
				disposable.Dispose();
			}
		}
	}

	// Token: 0x06000335 RID: 821 RVA: 0x00002973 File Offset: 0x00000B73
	private void _UpdateBone()
	{
	}

	// Token: 0x06000336 RID: 822 RVA: 0x00019A40 File Offset: 0x00017C40
	private void _LateUpdateBone()
	{
		this._UpdatePPHBones();
	}

	// Token: 0x06000337 RID: 823 RVA: 0x00019A48 File Offset: 0x00017C48
	private void _InitializePPHBones()
	{
		if (this._animator == null || this._animator.avatar == null || !this._animator.avatar.isValid || !this._animator.avatar.isHuman)
		{
			return;
		}
		Transform boneTransform = this._animator.GetBoneTransform(HumanBodyBones.LeftShoulder);
		Transform boneTransform2 = this._animator.GetBoneTransform(HumanBodyBones.LeftUpperArm);
		if (boneTransform != null && boneTransform2 != null)
		{
			this._leftShoulderBone = boneTransform.gameObject.GetComponent<MMD4MecanimBone>();
			this._leftArmBone = boneTransform2.gameObject.GetComponent<MMD4MecanimBone>();
			if (this._leftShoulderBone != null)
			{
				this._leftShoulderBone.humanBodyBones = 11;
			}
			if (this._leftArmBone != null)
			{
				this._leftArmBone.humanBodyBones = 13;
			}
		}
		Transform boneTransform3 = this._animator.GetBoneTransform(HumanBodyBones.RightShoulder);
		Transform boneTransform4 = this._animator.GetBoneTransform(HumanBodyBones.RightUpperArm);
		if (boneTransform3 != null && boneTransform4 != null)
		{
			this._rightShoulderBone = boneTransform3.gameObject.GetComponent<MMD4MecanimBone>();
			this._rightArmBone = boneTransform4.gameObject.GetComponent<MMD4MecanimBone>();
			if (this._rightShoulderBone != null)
			{
				this._rightShoulderBone.humanBodyBones = 12;
			}
			if (this._rightArmBone != null)
			{
				this._rightArmBone.humanBodyBones = 14;
			}
		}
	}

	// Token: 0x06000338 RID: 824 RVA: 0x00019A40 File Offset: 0x00017C40
	public void ForceUpdatePPHBones()
	{
		this._UpdatePPHBones();
	}

	// Token: 0x06000339 RID: 825 RVA: 0x00019BCB File Offset: 0x00017DCB
	private void _UpdatePPHBones()
	{
		this._pphShoulderFixRateImmediately = 0f;
	}

	// Token: 0x0600033A RID: 826 RVA: 0x00002973 File Offset: 0x00000B73
	private void _InitializeDeferredMaterial()
	{
	}

	// Token: 0x0600033B RID: 827 RVA: 0x00002973 File Offset: 0x00000B73
	private void _DestroyDeferredMaterial()
	{
	}

	// Token: 0x0600033C RID: 828 RVA: 0x00002973 File Offset: 0x00000B73
	private void _InitializeDeferredMesh()
	{
	}

	// Token: 0x0600033D RID: 829 RVA: 0x00019BD8 File Offset: 0x00017DD8
	private static GameObject _CreateDeferrecClearGameObject(GameObject parentGameObject)
	{
		return null;
	}

	// Token: 0x0600033E RID: 830 RVA: 0x00019BD8 File Offset: 0x00017DD8
	private Material[] _CloneDeferredClearMaterials(Material[] materials)
	{
		return null;
	}

	// Token: 0x0600033F RID: 831 RVA: 0x00002973 File Offset: 0x00000B73
	private void _UpdatedDeffered()
	{
	}

	// Token: 0x06000340 RID: 832 RVA: 0x00002973 File Offset: 0x00000B73
	private void _SetDeferredShaderSettings(Light directionalLight)
	{
	}

	// Token: 0x06000341 RID: 833 RVA: 0x00019BDB File Offset: 0x00017DDB
	private void _InitializeIK()
	{
		this._CheckTransformIK();
	}

	// Token: 0x06000342 RID: 834 RVA: 0x00019BE4 File Offset: 0x00017DE4
	private void _CheckTransformIK()
	{
		if (!Application.isPlaying)
		{
			return;
		}
		if (!this.fullBodyIKEnabled)
		{
			return;
		}
		if (this.fullBodyIKTargetList != null)
		{
			if (this.fullBodyIKTargetList.Length != 36)
			{
				this.fullBodyIKTargetList = null;
			}
			else
			{
				for (int num = 0; num != this.fullBodyIKTargetList.Length; num++)
				{
					if (this.fullBodyIKTargetList[num] == null)
					{
						this.fullBodyIKTargetList = null;
						break;
					}
				}
			}
		}
		if (this.fullBodyIKTargetList == null)
		{
			if (this._bulletPhysicsMMDModel == null)
			{
				return;
			}
			Vector3[] fullBodyIKPositionList = this._bulletPhysicsMMDModel.fullBodyIKPositionList;
			Quaternion[] fullBodyIKRotationList = this._bulletPhysicsMMDModel.fullBodyIKRotationList;
			if (fullBodyIKPositionList == null || fullBodyIKRotationList == null)
			{
				return;
			}
			if (fullBodyIKPositionList.Length != 36 || fullBodyIKRotationList.Length != 36)
			{
				return;
			}
			if (this.fullBodyIKTargets == null)
			{
				GameObject gameObject = new GameObject("FullBodyIKTargets");
				this.fullBodyIKTargets = gameObject.transform;
				this.fullBodyIKTargets.parent = base.transform;
				this.fullBodyIKTargets.localPosition = Vector3.zero;
				this.fullBodyIKTargets.localRotation = Quaternion.identity;
				this.fullBodyIKTargets.localScale = Vector3.one;
			}
			if (this.fullBodyIKGroupList == null || this.fullBodyIKGroupList.Length != 8)
			{
				this.fullBodyIKGroupList = new Transform[8];
				for (int num2 = 0; num2 != 8; num2++)
				{
					MMD4MecanimData.FullBodyIKGroup fullBodyIKGroup = (MMD4MecanimData.FullBodyIKGroup)num2;
					GameObject gameObject2 = new GameObject(fullBodyIKGroup.ToString());
					this.fullBodyIKGroupList[num2] = gameObject2.transform;
					this.fullBodyIKGroupList[num2].parent = this.fullBodyIKTargets;
					this.fullBodyIKGroupList[num2].localPosition = Vector3.zero;
					this.fullBodyIKGroupList[num2].localRotation = Quaternion.identity;
					this.fullBodyIKGroupList[num2].localScale = Vector3.one;
				}
			}
			MMD4MecanimBone rootBone = this.GetRootBone();
			Transform transform = null;
			if (rootBone != null)
			{
				transform = rootBone.transform;
			}
			this.fullBodyIKTargetList = new MMD4MecanimIKTarget[36];
			for (int num3 = 0; num3 != 36; num3++)
			{
				MMD4MecanimData.FullBodyIKGroup fullBodyIKGroup2;
				string fullBodyIKTargetName = MMD4MecanimData.GetFullBodyIKTargetName(out fullBodyIKGroup2, num3);
				if (fullBodyIKGroup2 != MMD4MecanimData.FullBodyIKGroup.Unknown)
				{
					GameObject gameObject3 = new GameObject(fullBodyIKTargetName);
					Transform transform2 = gameObject3.transform;
					Vector3 position = fullBodyIKPositionList[num3];
					Quaternion quaternion = fullBodyIKRotationList[num3];
					if (transform != null)
					{
						position = transform.TransformPoint(position);
						quaternion = transform.rotation * quaternion;
					}
					transform2.parent = this.fullBodyIKGroupList[(int)fullBodyIKGroup2];
					transform2.position = position;
					transform2.rotation = quaternion;
					transform2.localScale = Vector3.one;
					this.fullBodyIKTargetList[num3] = gameObject3.AddComponent<MMD4MecanimIKTarget>();
					this.fullBodyIKTargetList[num3].model = this;
				}
			}
		}
	}

	// Token: 0x06000343 RID: 835 RVA: 0x00019BDB File Offset: 0x00017DDB
	private void _UpdateIK()
	{
		this._CheckTransformIK();
	}

	// Token: 0x06000344 RID: 836 RVA: 0x00019ED0 File Offset: 0x000180D0
	private void _LateUpdateIK()
	{
		if (!Application.isPlaying)
		{
			return;
		}
		if (this._bulletPhysicsMMDModel == null)
		{
			return;
		}
		int[] updateFullBodyIKFlagsList = this._bulletPhysicsMMDModel.updateFullBodyIKFlagsList;
		float[] updateFullBodyIKTransformList = this._bulletPhysicsMMDModel.updateFullBodyIKTransformList;
		float[] updateFullBodyIKWeightList = this._bulletPhysicsMMDModel.updateFullBodyIKWeightList;
		if (updateFullBodyIKFlagsList == null || updateFullBodyIKTransformList == null || updateFullBodyIKWeightList == null)
		{
			return;
		}
		if (updateFullBodyIKFlagsList.Length != 36 || updateFullBodyIKTransformList.Length != 144 || updateFullBodyIKWeightList.Length != 36)
		{
			return;
		}
		if (this.fullBodyIKTargetList != null && this.fullBodyIKTargetList.Length == 36)
		{
			int num = 0;
			int num2 = 0;
			while (num != 36)
			{
				MMD4MecanimIKTarget mmd4MecanimIKTarget = this.fullBodyIKTargetList[num];
				if (mmd4MecanimIKTarget != null)
				{
					Vector3 position = mmd4MecanimIKTarget.transform.position;
					updateFullBodyIKTransformList[num2] = position.x;
					updateFullBodyIKTransformList[num2 + 1] = position.y;
					updateFullBodyIKTransformList[num2 + 2] = position.z;
					updateFullBodyIKTransformList[num2 + 3] = 1f;
					updateFullBodyIKWeightList[num] = mmd4MecanimIKTarget.ikWeight;
				}
				num++;
				num2 += 4;
			}
		}
	}

	// Token: 0x06000345 RID: 837 RVA: 0x00002973 File Offset: 0x00000B73
	private void _UpdateAmbientPreview()
	{
	}

	// Token: 0x06000346 RID: 838 RVA: 0x00002973 File Offset: 0x00000B73
	private void _UpdateAmbientPreviewInternal(Material[] materials)
	{
	}

	// Token: 0x06000347 RID: 839 RVA: 0x00002973 File Offset: 0x00000B73
	private void _InitializeGlobalAmbient()
	{
	}

	// Token: 0x06000348 RID: 840 RVA: 0x00002973 File Offset: 0x00000B73
	private void _UpdateGlobalAmbient()
	{
	}

	// Token: 0x06000349 RID: 841 RVA: 0x00002973 File Offset: 0x00000B73
	private void _CleanupGlobalAmbient()
	{
	}

	// Token: 0x0600034A RID: 842 RVA: 0x00019FE4 File Offset: 0x000181E4
	private void _UpdateAutoLuminous()
	{
		if (this.morphAutoLuminous != null && this.morphAutoLuminous.updated && this._cloneMaterials != null)
		{
			for (int num = 0; num != this._cloneMaterials.Length; num++)
			{
				MMD4MecanimModel.CloneMaterial cloneMaterial = this._cloneMaterials[num];
				if (cloneMaterial.updateMaterialData != null && cloneMaterial.materialData != null && cloneMaterial.materials != null)
				{
					for (int i = 0; i < cloneMaterial.updateMaterialData.Length; i++)
					{
						if (!cloneMaterial.updateMaterialData[i])
						{
							float shininess = cloneMaterial.materialData[i].shininess;
							if (shininess > 100f)
							{
								cloneMaterial.updateMaterialData[i] = true;
							}
						}
					}
				}
			}
		}
	}

	// Token: 0x0600034B RID: 843 RVA: 0x0001A0A6 File Offset: 0x000182A6
	private void _CleanupAutoLuminous()
	{
		if (this.morphAutoLuminous != null)
		{
			this.morphAutoLuminous.updated = false;
		}
	}

	// Token: 0x17000075 RID: 117
	// (get) Token: 0x0600034C RID: 844 RVA: 0x0001A0BF File Offset: 0x000182BF
	public int _skinnedMeshCount
	{
		get
		{
			if (this._skinnedMeshRenderers != null)
			{
				return this._skinnedMeshRenderers.Length;
			}
			return 0;
		}
	}

	// Token: 0x17000076 RID: 118
	// (get) Token: 0x0600034D RID: 845 RVA: 0x0001A0D6 File Offset: 0x000182D6
	public int _cloneMeshCount
	{
		get
		{
			if (this._cloneMeshes != null)
			{
				return this._cloneMeshes.Length;
			}
			return 0;
		}
	}

	// Token: 0x0600034E RID: 846 RVA: 0x0001A0F0 File Offset: 0x000182F0
	public void _UploadMeshVertex(int meshID, Vector3[] vertices, Vector3[] normals)
	{
		if (this._cloneMeshes != null && meshID >= 0 && meshID < this._cloneMeshes.Length)
		{
			MMD4MecanimModel.CloneMesh cloneMesh = this._cloneMeshes[meshID];
			if (cloneMesh != null)
			{
				if (vertices != null)
				{
					cloneMesh.mesh.vertices = vertices;
				}
				if (normals != null)
				{
					cloneMesh.mesh.normals = normals;
				}
			}
		}
	}

	// Token: 0x0600034F RID: 847 RVA: 0x0001A150 File Offset: 0x00018350
	private void _UploadMeshMaterial()
	{
		if (!Application.isPlaying)
		{
			return;
		}
		this._UpdateGlobalAmbient();
		this._UpdateAutoLuminous();
		if (this._cloneMaterials != null)
		{
			for (int num = 0; num != this._cloneMaterials.Length; num++)
			{
				MMD4MecanimModel.CloneMaterial cloneMaterial = this._cloneMaterials[num];
				if (cloneMaterial.updateMaterialData != null && cloneMaterial.materialData != null && cloneMaterial.materials != null)
				{
					for (int i = 0; i < cloneMaterial.updateMaterialData.Length; i++)
					{
						if (cloneMaterial.updateMaterialData[i])
						{
							cloneMaterial.updateMaterialData[i] = false;
							MMD4MecanimCommon.FeedbackMaterial(ref cloneMaterial.materialData[i], cloneMaterial.materials[i], this.morphAutoLuminous);
						}
					}
				}
			}
		}
		this._CleanupGlobalAmbient();
		this._CleanupAutoLuminous();
	}

	// Token: 0x06000350 RID: 848 RVA: 0x0001A21C File Offset: 0x0001841C
	public int[] _PrepareMeshFlags()
	{
		if (this._skinnedMeshRenderers != null)
		{
			int num = this._skinnedMeshRenderers.Length;
			if (num > 0)
			{
				return new int[num];
			}
		}
		return null;
	}

	// Token: 0x06000351 RID: 849 RVA: 0x0001A24C File Offset: 0x0001844C
	public int[] _PrepareMeshFlags(out bool blendShapesAnything)
	{
		blendShapesAnything = false;
		if (this._skinnedMeshRenderers != null)
		{
			int num = this._skinnedMeshRenderers.Length;
			if (num > 0)
			{
				int[] array = new int[num];
				if (this.vertexMorphEnabled && this.blendShapesEnabled)
				{
					for (int num2 = 0; num2 != num; num2++)
					{
						SkinnedMeshRenderer skinnedMeshRenderer = this._skinnedMeshRenderers[num2];
						if (skinnedMeshRenderer != null && skinnedMeshRenderer.sharedMesh != null && skinnedMeshRenderer.sharedMesh.blendShapeCount != 0)
						{
							array[num2] |= 1;
							blendShapesAnything = true;
						}
					}
				}
				return array;
			}
		}
		return null;
	}

	// Token: 0x06000352 RID: 850 RVA: 0x0001A2F0 File Offset: 0x000184F0
	public void _InitializeCloneMesh(int[] meshFlags)
	{
		int num = 0;
		int num2 = 0;
		if (this._meshRenderers != null)
		{
			num2 += this._meshRenderers.Length;
		}
		if (this._skinnedMeshRenderers != null)
		{
			num2 += this._skinnedMeshRenderers.Length;
		}
		if (num2 > 0)
		{
			this._cloneMaterials = new MMD4MecanimModel.CloneMaterial[num2];
		}
		if (this._meshRenderers != null)
		{
			for (int num3 = 0; num3 != this._meshRenderers.Length; num3++)
			{
				MeshRenderer meshRenderer = this._meshRenderers[num3];
				Material[] array = null;
				if (Application.isPlaying)
				{
					array = meshRenderer.materials;
				}
				if (array == null)
				{
					array = meshRenderer.sharedMaterials;
				}
				MMD4MecanimModel._PostfixRenderQueue(array, this.postfixRenderQueue, this.renderQueueAfterSkybox);
				this._cloneMaterials[num] = new MMD4MecanimModel.CloneMaterial();
				MMD4MecanimModel._SetupCloneMaterial(this._cloneMaterials[num], array);
				num++;
			}
		}
		bool flag = false;
		if (meshFlags != null && this._skinnedMeshRenderers != null && meshFlags.Length == this._skinnedMeshRenderers.Length && Application.isPlaying)
		{
			int num4 = 0;
			while (num4 != meshFlags.Length && !flag)
			{
				flag = ((meshFlags[num4] & 6) != 0);
				num4++;
			}
		}
		if (this._skinnedMeshRenderers != null)
		{
			if (flag)
			{
				this._cloneMeshes = new MMD4MecanimModel.CloneMesh[this._skinnedMeshRenderers.Length];
			}
			for (int num5 = 0; num5 != this._skinnedMeshRenderers.Length; num5++)
			{
				SkinnedMeshRenderer skinnedMeshRenderer = this._skinnedMeshRenderers[num5];
				if ((meshFlags[num5] & 6) != 0)
				{
					this._cloneMeshes[num5] = new MMD4MecanimModel.CloneMesh();
					MMD4MecanimCommon.CloneMeshWork cloneMeshWork = MMD4MecanimCommon.CloneMesh(skinnedMeshRenderer.sharedMesh);
					if (cloneMeshWork != null && cloneMeshWork.mesh != null)
					{
						this._cloneMeshes[num5].skinnedMeshRenderer = skinnedMeshRenderer;
						this._cloneMeshes[num5].mesh = cloneMeshWork.mesh;
						if (this._cloneMeshes[num5].mesh != null)
						{
							this._cloneMeshes[num5].mesh.MarkDynamic();
						}
						this._cloneMeshes[num5].vertices = cloneMeshWork.vertices;
						if ((meshFlags[num5] & 4) != 0)
						{
							if (this.xdefNormalEnabled)
							{
								this._cloneMeshes[num5].normals = cloneMeshWork.normals;
							}
							this._cloneMeshes[num5].bindposes = cloneMeshWork.bindposes;
							this._cloneMeshes[num5].boneWeights = cloneMeshWork.boneWeights;
						}
						skinnedMeshRenderer.sharedMesh = this._cloneMeshes[num5].mesh;
					}
					else
					{
						Debug.LogError("CloneMesh() Failed. : " + base.gameObject.name);
					}
				}
				Material[] array2 = null;
				if (Application.isPlaying)
				{
					array2 = skinnedMeshRenderer.materials;
				}
				if (array2 == null)
				{
					array2 = skinnedMeshRenderer.sharedMaterials;
				}
				MMD4MecanimModel._PostfixRenderQueue(array2, this.postfixRenderQueue, this.renderQueueAfterSkybox);
				this._cloneMaterials[num] = new MMD4MecanimModel.CloneMaterial();
				MMD4MecanimModel._SetupCloneMaterial(this._cloneMaterials[num], array2);
				num++;
			}
		}
		if (this._cloneMaterials != null)
		{
			for (int num6 = 0; num6 != this._cloneMaterials.Length; num6++)
			{
				Material[] materials = this._cloneMaterials[num6].materials;
				if (materials != null)
				{
					for (int num7 = 0; num7 != materials.Length; num7++)
					{
						if (MMD4MecanimCommon.IsDeferredShader(materials[num7]))
						{
							this._supportDeferred = true;
							break;
						}
					}
					if (this._supportDeferred)
					{
						break;
					}
				}
			}
		}
	}

	// Token: 0x06000353 RID: 851 RVA: 0x0001A677 File Offset: 0x00018877
	public MMD4MecanimModel.CloneMesh _GetCloneMesh(int meshIndex)
	{
		if (this._cloneMeshes != null && meshIndex >= 0 && meshIndex < this._cloneMeshes.Length)
		{
			return this._cloneMeshes[meshIndex];
		}
		return null;
	}

	// Token: 0x06000354 RID: 852 RVA: 0x0001A6A4 File Offset: 0x000188A4
	public void _CleanupCloneMesh()
	{
		if (this._cloneMeshes != null)
		{
			for (int num = 0; num != this._cloneMeshes.Length; num++)
			{
				if (this._cloneMeshes[num] != null)
				{
					if (!this.xdefNormalEnabled)
					{
						this._cloneMeshes[num].normals = null;
					}
					this._cloneMeshes[num].bindposes = null;
					this._cloneMeshes[num].boneWeights = null;
				}
			}
		}
	}

	// Token: 0x06000355 RID: 853 RVA: 0x0001A717 File Offset: 0x00018917
	public MMD4MecanimModel.Morph GetMorph(string morphName)
	{
		return this.GetMorph(morphName, false);
	}

	// Token: 0x06000356 RID: 854 RVA: 0x0001A724 File Offset: 0x00018924
	public MMD4MecanimModel.Morph GetMorph(string morphName, bool isStartsWith)
	{
		if (this.modelData != null)
		{
			int num = this.modelData.GetMorphDataIndexJp(morphName, isStartsWith);
			if (num != -1)
			{
				return this.morphList[num];
			}
			if (!isStartsWith)
			{
				num = this.modelData.GetMorphDataIndexEn(morphName, false);
				if (num != -1)
				{
					return this.morphList[num];
				}
				num = this.modelData.GetTranslatedMorphDataIndex(morphName, false);
				if (num != -1)
				{
					return this.morphList[num];
				}
			}
		}
		return null;
	}

	// Token: 0x06000357 RID: 855 RVA: 0x0001A79D File Offset: 0x0001899D
	public void ForceUpdateMorph()
	{
		this._UpdateMorph();
	}

	// Token: 0x06000358 RID: 856 RVA: 0x0001A7A8 File Offset: 0x000189A8
	private void _UpdateMorph()
	{
		if (this.morphList != null && this._animMorphCategoryWeights != null)
		{
			for (int num = 0; num != this._animMorphCategoryWeights.Length; num++)
			{
				this._animMorphCategoryWeights[num] = 1f;
			}
			for (int num2 = 0; num2 != this.morphList.Length; num2++)
			{
				MMD4MecanimModel.Morph morph = this.morphList[num2];
				switch (morph.morphCategory)
				{
				case MMD4MecanimData.MorphCategory.EyeBrow:
				case MMD4MecanimData.MorphCategory.Eye:
				case MMD4MecanimData.MorphCategory.Lip:
					if (morph.weight2 != 0f)
					{
						if (morph.weight2 == 1f)
						{
							this._animMorphCategoryWeights[(int)morph.morphCategory] = 0f;
						}
						else
						{
							this._animMorphCategoryWeights[(int)morph.morphCategory] = Mathf.Min(this._animMorphCategoryWeights[(int)morph.morphCategory], 1f - morph.weight2);
						}
					}
					break;
				}
			}
			bool flag = false;
			for (int num3 = 0; num3 != this.morphList.Length; num3++)
			{
				this.morphList[num3]._updateWeight = MMD4MecanimModel._GetMorphUpdateWeight(this.morphList[num3], this._animMorphCategoryWeights);
				flag |= (this.morphList[num3]._updateWeight != this.morphList[num3]._updatedWeight);
			}
			if (flag)
			{
				for (int num4 = 0; num4 != this.morphList.Length; num4++)
				{
					this.morphList[num4]._appendWeight = 0f;
				}
				if (this._modelData != null && this._modelData.morphDataList != null)
				{
					bool flag2 = false;
					for (int num5 = 0; num5 != this._modelData.morphDataList.Length; num5++)
					{
						if (this._modelData.morphDataList[num5].morphType == MMD4MecanimData.MorphType.Group)
						{
							flag2 = true;
							this._ApplyMorph(num5);
						}
					}
					for (int num6 = 0; num6 != this.morphList.Length; num6++)
					{
						if (this._modelData.morphDataList[num6].morphType != MMD4MecanimData.MorphType.Group)
						{
							if (flag2)
							{
								this.morphList[num6]._updateWeight = MMD4MecanimModel._GetMorphUpdateWeight(this.morphList[num6], this._animMorphCategoryWeights);
							}
							this._ApplyMorph(num6);
						}
					}
				}
			}
		}
	}

	// Token: 0x06000359 RID: 857 RVA: 0x0001AA08 File Offset: 0x00018C08
	private void _ApplyMorph(int morphIndex)
	{
		if ((this._morphBlendShapes == null && this._cloneMeshes == null) || this.morphList == null || morphIndex >= this.morphList.Length)
		{
			return;
		}
		MMD4MecanimModel.Morph morph = this.morphList[morphIndex];
		if (morph == null)
		{
			return;
		}
		float num = morph._updateWeight;
		morph._updatedWeight = num;
		if (this._modelData == null || this._modelData.morphDataList == null || morphIndex >= this._modelData.morphDataList.Length)
		{
			return;
		}
		MMD4MecanimData.MorphData morphData = this._modelData.morphDataList[morphIndex];
		if (this.morphAutoLuminous != null && morph.morphAutoLuminousType != MMD4MecanimData.MorphAutoLumninousType.None)
		{
			switch (morph.morphAutoLuminousType)
			{
			case MMD4MecanimData.MorphAutoLumninousType.LightUp:
				if (this.morphAutoLuminous.lightUp != num)
				{
					this.morphAutoLuminous.lightUp = num;
					this.morphAutoLuminous.updated = true;
				}
				break;
			case MMD4MecanimData.MorphAutoLumninousType.LightOff:
				if (this.morphAutoLuminous.lightOff != num)
				{
					this.morphAutoLuminous.lightOff = num;
					this.morphAutoLuminous.updated = true;
				}
				break;
			case MMD4MecanimData.MorphAutoLumninousType.LightBlink:
				if (this.morphAutoLuminous.lightBlink != num)
				{
					this.morphAutoLuminous.lightBlink = num;
					this.morphAutoLuminous.updated = true;
				}
				break;
			case MMD4MecanimData.MorphAutoLumninousType.LightBS:
				if (this.morphAutoLuminous.lightBS != num)
				{
					this.morphAutoLuminous.lightBS = num;
					this.morphAutoLuminous.updated = true;
				}
				break;
			}
		}
		if (morphData.morphType == MMD4MecanimData.MorphType.Group)
		{
			if (morphData.indices == null)
			{
				return;
			}
			for (int i = 0; i < morphData.indices.Length; i++)
			{
				int num2 = morphData.indices[i];
				if (num2 < this.morphList.Length)
				{
					this.morphList[num2]._appendWeight += num;
				}
			}
		}
		else if (morphData.morphType == MMD4MecanimData.MorphType.Vertex)
		{
			if (this._blendShapesEnabledCache && this._morphBlendShapes != null)
			{
				num *= 100f;
				if (this._skinnedMeshRenderers != null && this._skinnedMeshRenderers.Length == this._morphBlendShapes.Length)
				{
					for (int num3 = 0; num3 != this._morphBlendShapes.Length; num3++)
					{
						if (this._morphBlendShapes[num3].blendShapeIndices != null && morphIndex < this._morphBlendShapes[num3].blendShapeIndices.Length)
						{
							int num4 = this._morphBlendShapes[num3].blendShapeIndices[morphIndex];
							if (num4 != -1 && this._skinnedMeshRenderers[num3] != null)
							{
								this._skinnedMeshRenderers[num3].SetBlendShapeWeight(num4, num);
							}
						}
					}
				}
				return;
			}
		}
		else if (morphData.morphType == MMD4MecanimData.MorphType.Material)
		{
			if (morphData.materialData == null)
			{
				return;
			}
			if (this.materialMorphEnabled)
			{
				for (int num5 = 0; num5 != morphData.materialData.Length; num5++)
				{
					this._ApplyMaterialData(ref morphData.materialData[num5], num);
				}
			}
		}
	}

	// Token: 0x0600035A RID: 858 RVA: 0x0001AD30 File Offset: 0x00018F30
	private void _ApplyMaterialData(ref MMD4MecanimData.MorphMaterialData morphMaterialData, float weight)
	{
		if (this._cloneMaterials != null)
		{
			for (int num = 0; num != this._cloneMaterials.Length; num++)
			{
				MMD4MecanimModel.CloneMaterial cloneMaterial = this._cloneMaterials[num];
				if (cloneMaterial.backupMaterialData != null && cloneMaterial.updateMaterialData != null && cloneMaterial.materialData != null && cloneMaterial.materials != null)
				{
					for (int i = 0; i < cloneMaterial.updateMaterialData.Length; i++)
					{
						if (cloneMaterial.backupMaterialData[i].materialID == morphMaterialData.materialID)
						{
							if (!cloneMaterial.updateMaterialData[i])
							{
								cloneMaterial.updateMaterialData[i] = true;
								cloneMaterial.materialData[i] = cloneMaterial.backupMaterialData[i];
							}
							MMD4MecanimCommon.OperationMaterial(ref cloneMaterial.materialData[i], ref morphMaterialData, weight);
						}
					}
				}
			}
		}
	}

	// Token: 0x0600035B RID: 859 RVA: 0x0001AE16 File Offset: 0x00019016
	private static float _FastScl(float weight, float weight2)
	{
		if (weight2 == 0f)
		{
			return 0f;
		}
		if (weight2 == 1f)
		{
			return weight;
		}
		return weight * weight2;
	}

	// Token: 0x0600035C RID: 860 RVA: 0x0001AE3C File Offset: 0x0001903C
	private static float _GetMorphUpdateWeight(MMD4MecanimModel.Morph morph, float[] animMorphCategoryWeights)
	{
		float b = animMorphCategoryWeights[(int)morph.morphCategory];
		float weight = Mathf.Min(1f - morph.weight2, b);
		return Mathf.Min(1f, Mathf.Max(morph.weight, MMD4MecanimModel._FastScl(morph._animWeight + morph._appendWeight, weight)));
	}

	// Token: 0x0600035D RID: 861 RVA: 0x0001AE90 File Offset: 0x00019090
	private void _InitializeNEXTMaterial()
	{
		if ((this.nextEdgeMaterial_Pass4 == null || this.nextEdgeMaterial_Pass4.shader == null) && !this._notFoundShaderNEXTPass4)
		{
			Shader shader = Shader.Find("MMD4Mecanim/MMDLit-NEXTEdge-Pass4");
			if (shader != null)
			{
				this.nextEdgeMaterial_Pass4 = new Material(shader);
			}
			else
			{
				this._notFoundShaderNEXTPass4 = true;
			}
		}
		if ((this.nextEdgeMaterial_Pass8 == null || this.nextEdgeMaterial_Pass8.shader == null) && !this._notFoundShaderNEXTPass8)
		{
			Shader shader2 = Shader.Find("MMD4Mecanim/MMDLit-NEXTEdge-Pass8");
			if (shader2 != null)
			{
				this.nextEdgeMaterial_Pass8 = new Material(shader2);
			}
			else
			{
				this._notFoundShaderNEXTPass8 = true;
			}
		}
		this._PostfixNEXTMaterial();
	}

	// Token: 0x0600035E RID: 862 RVA: 0x0001AF68 File Offset: 0x00019168
	private void _DestroyNEXTMaterial()
	{
		if (this.nextEdgeMaterial_Pass4 != null)
		{
			if (Application.isPlaying)
			{
				UnityEngine.Object.Destroy(this.nextEdgeMaterial_Pass4);
			}
			else
			{
				UnityEngine.Object.DestroyImmediate(this.nextEdgeMaterial_Pass4);
			}
			this.nextEdgeMaterial_Pass4 = null;
		}
		if (this.nextEdgeMaterial_Pass8 != null)
		{
			if (Application.isPlaying)
			{
				UnityEngine.Object.Destroy(this.nextEdgeMaterial_Pass8);
			}
			else
			{
				UnityEngine.Object.DestroyImmediate(this.nextEdgeMaterial_Pass8);
			}
			this.nextEdgeMaterial_Pass8 = null;
		}
	}

	// Token: 0x0600035F RID: 863 RVA: 0x0001AFF0 File Offset: 0x000191F0
	private void _PostfixNEXTMaterial()
	{
		if (this.postfixRenderQueue)
		{
			int renderQueue = (!this.renderQueueAfterSkybox) ? 2001 : 2501;
			if (this.nextEdgeMaterial_Pass4 != null && this.nextEdgeMaterial_Pass4.GetFloat("_PostfixRenderQueue") <= 0.5f)
			{
				this.nextEdgeMaterial_Pass4.SetFloat("_PostfixRenderQueue", 1f);
				this.nextEdgeMaterial_Pass4.renderQueue = renderQueue;
			}
			if (this.nextEdgeMaterial_Pass8 != null && this.nextEdgeMaterial_Pass8.GetFloat("_PostfixRenderQueue") <= 0.5f)
			{
				this.nextEdgeMaterial_Pass8.SetFloat("_PostfixRenderQueue", 1f);
				this.nextEdgeMaterial_Pass8.renderQueue = renderQueue;
			}
		}
		else
		{
			if (this.nextEdgeMaterial_Pass4 != null && this.nextEdgeMaterial_Pass4.GetFloat("_PostfixRenderQueue") > 0.5f)
			{
				this.nextEdgeMaterial_Pass4.SetFloat("_PostfixRenderQueue", 0f);
				this.nextEdgeMaterial_Pass4.renderQueue = -1;
			}
			if (this.nextEdgeMaterial_Pass8 != null && this.nextEdgeMaterial_Pass8.GetFloat("_PostfixRenderQueue") > 0.5f)
			{
				this.nextEdgeMaterial_Pass8.SetFloat("_PostfixRenderQueue", 0f);
				this.nextEdgeMaterial_Pass8.renderQueue = -1;
			}
		}
	}

	// Token: 0x06000360 RID: 864 RVA: 0x0001B158 File Offset: 0x00019358
	private void _InitializeNEXTEdgeMesh()
	{
		if (!this.supportNEXTEdge)
		{
			return;
		}
		this._InitializeNEXTMaterial();
		if (this.nextEdgeMaterial_Pass4 == null)
		{
			Debug.LogWarning("nextEdgeMaterial_Pass4 is null. Skipped _InitializenextEdgeMesh().");
			return;
		}
		if (this.nextEdgeMaterial_Pass8 == null)
		{
			Debug.LogWarning("nextEdgeMaterial_Pass8 is null. Skipped _InitializenextEdgeMesh().");
			return;
		}
		bool flag = this.nextEdgeSize > 0f;
		this._nextEdgeVisibleCached = flag;
		if (this._meshRenderers != null)
		{
			this._nextEdgeMeshRenderers = new MeshRenderer[this._meshRenderers.Length];
			for (int i = 0; i < this._meshRenderers.Length; i++)
			{
				MeshRenderer meshRenderer = this._meshRenderers[i];
				if (meshRenderer != null)
				{
					Material[] array = meshRenderer.sharedMaterials;
					if (array == null || array.Length == 0)
					{
						array = meshRenderer.materials;
					}
					if (array != null)
					{
						array = this._CloneNEXTEdgeMaterials(array);
					}
					if (array != null)
					{
						GameObject gameObject = MMD4MecanimModel._CreateNEXTEdgeGameObject(meshRenderer.gameObject);
						MeshRenderer meshRenderer2 = gameObject.AddComponent<MeshRenderer>();
						meshRenderer2.enabled = flag;
						meshRenderer2.shadowCastingMode = ShadowCastingMode.Off;
						meshRenderer2.receiveShadows = false;
						meshRenderer2.materials = array;
						MeshFilter component = this._meshRenderers[i].gameObject.GetComponent<MeshFilter>();
						if (component != null)
						{
							MeshFilter meshFilter = gameObject.AddComponent<MeshFilter>();
							meshFilter.sharedMesh = component.sharedMesh;
						}
						this._nextEdgeMeshRenderers[i] = meshRenderer2;
					}
				}
			}
		}
		if (this._skinnedMeshRenderers != null)
		{
			this._nextEdgeSkinnedMeshRenderers = new SkinnedMeshRenderer[this._skinnedMeshRenderers.Length];
			for (int j = 0; j < this._skinnedMeshRenderers.Length; j++)
			{
				SkinnedMeshRenderer skinnedMeshRenderer = this._skinnedMeshRenderers[j];
				if (skinnedMeshRenderer != null)
				{
					Material[] array2 = skinnedMeshRenderer.sharedMaterials;
					if (array2 == null || array2.Length == 0)
					{
						array2 = skinnedMeshRenderer.materials;
					}
					if (array2 != null)
					{
						array2 = this._CloneNEXTEdgeMaterials(array2);
					}
					if (array2 != null)
					{
						GameObject gameObject2 = MMD4MecanimModel._CreateNEXTEdgeGameObject(skinnedMeshRenderer.gameObject);
						SkinnedMeshRenderer skinnedMeshRenderer2 = gameObject2.AddComponent<SkinnedMeshRenderer>();
						skinnedMeshRenderer2.sharedMesh = skinnedMeshRenderer.sharedMesh;
						skinnedMeshRenderer2.bones = skinnedMeshRenderer.bones;
						skinnedMeshRenderer2.rootBone = skinnedMeshRenderer.rootBone;
						skinnedMeshRenderer2.shadowCastingMode = ShadowCastingMode.Off;
						skinnedMeshRenderer2.receiveShadows = false;
						skinnedMeshRenderer2.materials = array2;
						skinnedMeshRenderer2.enabled = flag;
						this._nextEdgeSkinnedMeshRenderers[j] = skinnedMeshRenderer2;
					}
				}
			}
		}
		this._UpdatedNEXTEdge();
	}

	// Token: 0x06000361 RID: 865 RVA: 0x0001B3B8 File Offset: 0x000195B8
	private static GameObject _CreateNEXTEdgeGameObject(GameObject parentGameObject)
	{
		if (parentGameObject != null)
		{
			return new GameObject(parentGameObject.name + "(NEXTEdge)")
			{
				transform = 
				{
					parent = parentGameObject.transform,
					localPosition = Vector3.zero,
					localRotation = Quaternion.identity,
					localScale = Vector3.one
				}
			};
		}
		return null;
	}

	// Token: 0x06000362 RID: 866 RVA: 0x0001B42C File Offset: 0x0001962C
	private Material[] _CloneNEXTEdgeMaterials(Material[] materials)
	{
		if (materials != null)
		{
			Material[] array = new Material[materials.Length];
			for (int i = 0; i < materials.Length; i++)
			{
				if (materials[i] != null && materials[i].shader != null)
				{
					if (this.nextEdgePass == MMD4MecanimModel.NEXTEdgePass.Pass4)
					{
						array[i] = this.nextEdgeMaterial_Pass4;
					}
					else
					{
						array[i] = this.nextEdgeMaterial_Pass8;
					}
				}
			}
			return array;
		}
		return null;
	}

	// Token: 0x06000363 RID: 867 RVA: 0x0001B4A4 File Offset: 0x000196A4
	private void _UpdatedNEXTEdge()
	{
		if (!this.supportNEXTEdge)
		{
			return;
		}
		bool flag = this.nextEdgeSize > 0f;
		if (this._nextEdgeVisibleCached != flag)
		{
			this._nextEdgeVisibleCached = flag;
			if (this._nextEdgeMeshRenderers != null)
			{
				for (int num = 0; num != this._nextEdgeMeshRenderers.Length; num++)
				{
					this._nextEdgeMeshRenderers[num].enabled = flag;
				}
			}
			if (this._nextEdgeSkinnedMeshRenderers != null)
			{
				for (int num2 = 0; num2 != this._nextEdgeSkinnedMeshRenderers.Length; num2++)
				{
					this._nextEdgeSkinnedMeshRenderers[num2].enabled = flag;
				}
			}
		}
		if (this._nextEdgeSizeCached != this.nextEdgeSize || this._nextEdgeColorCached != this.nextEdgeColor)
		{
			this._nextEdgeSizeCached = this.nextEdgeSize;
			this._nextEdgeColorCached = this.nextEdgeColor;
			if (this.nextEdgeMaterial_Pass4 != null)
			{
				this.nextEdgeMaterial_Pass4.SetFloat("_EdgeSize", this._nextEdgeSizeCached * 0.05f);
				this.nextEdgeMaterial_Pass4.SetColor("_EdgeColor", this._nextEdgeColorCached);
			}
			if (this.nextEdgeMaterial_Pass8 != null)
			{
				this.nextEdgeMaterial_Pass8.SetFloat("_EdgeSize", this._nextEdgeSizeCached * 0.05f);
				this.nextEdgeMaterial_Pass8.SetColor("_EdgeColor", this._nextEdgeColorCached);
			}
		}
	}

	// Token: 0x06000364 RID: 868 RVA: 0x0001B608 File Offset: 0x00019808
	private void _InitializeRigidBody()
	{
		if (this._modelData == null)
		{
			this.rigidBodyList = null;
			return;
		}
		if (this._modelData.rigidBodyDataList == null)
		{
			this.rigidBodyList = null;
			return;
		}
		if (this.rigidBodyList != null)
		{
			for (int num = 0; num != this.rigidBodyList.Length; num++)
			{
				if (this.rigidBodyList[num] == null)
				{
					this.rigidBodyList = null;
					break;
				}
			}
		}
		if (this.rigidBodyList == null || this.rigidBodyList.Length != this._modelData.rigidBodyDataList.Length)
		{
			this.rigidBodyList = new MMD4MecanimModel.RigidBody[this._modelData.rigidBodyDataList.Length];
			for (int num2 = 0; num2 != this.rigidBodyList.Length; num2++)
			{
				this.rigidBodyList[num2] = new MMD4MecanimModel.RigidBody();
				this.rigidBodyList[num2].rigidBodyData = this._modelData.rigidBodyDataList[num2];
				this.rigidBodyList[num2].freezed = this.rigidBodyList[num2].rigidBodyData.isFreezed;
			}
		}
		else
		{
			for (int num3 = 0; num3 != this.rigidBodyList.Length; num3++)
			{
				this.rigidBodyList[num3].rigidBodyData = this._modelData.rigidBodyDataList[num3];
			}
		}
	}

	// Token: 0x06000365 RID: 869 RVA: 0x0001B754 File Offset: 0x00019954
	private void _InitializePhysicsEngine()
	{
		if (this.modelFile == null)
		{
			Debug.LogWarning(base.gameObject.name + ":modelFile is nothing.");
			return;
		}
		if (this.physicsEngine == MMD4MecanimModel.PhysicsEngine.None || this.physicsEngine == MMD4MecanimModel.PhysicsEngine.BulletPhysics)
		{
			MMD4MecanimBulletPhysics instance = MMD4MecanimBulletPhysics.instance;
			if (instance != null)
			{
				this._bulletPhysicsMMDModel = instance.CreateMMDModel(this);
			}
		}
	}

	// Token: 0x06000366 RID: 870 RVA: 0x0001B7C4 File Offset: 0x000199C4
	public void SetGravity(float gravityScale, float gravityNoise, Vector3 gravityDirection)
	{
		if (this.bulletPhysics != null && this.bulletPhysics.worldProperty != null)
		{
			this.bulletPhysics.worldProperty.gravityScale = gravityScale;
			this.bulletPhysics.worldProperty.gravityNoise = gravityNoise;
			this.bulletPhysics.worldProperty.gravityDirection = gravityDirection;
		}
	}

	// Token: 0x17000077 RID: 119
	// (get) Token: 0x06000367 RID: 871 RVA: 0x0001B81F File Offset: 0x00019A1F
	public float pphShoulderFixRateImmediately
	{
		get
		{
			return this._pphShoulderFixRateImmediately;
		}
	}

	// Token: 0x17000078 RID: 120
	// (get) Token: 0x06000368 RID: 872 RVA: 0x0001B827 File Offset: 0x00019A27
	public MMD4MecanimData.ModelData modelData
	{
		get
		{
			return this._modelData;
		}
	}

	// Token: 0x17000079 RID: 121
	// (get) Token: 0x06000369 RID: 873 RVA: 0x0001B82F File Offset: 0x00019A2F
	public byte[] modelFileBytes
	{
		get
		{
			return (!(this.modelFile != null)) ? null : this.modelFile.bytes;
		}
	}

	// Token: 0x1700007A RID: 122
	// (get) Token: 0x0600036A RID: 874 RVA: 0x0001B853 File Offset: 0x00019A53
	public byte[] indexFileBytes
	{
		get
		{
			return (!(this.indexFile != null)) ? null : this.indexFile.bytes;
		}
	}

	// Token: 0x1700007B RID: 123
	// (get) Token: 0x0600036B RID: 875 RVA: 0x0001B877 File Offset: 0x00019A77
	public byte[] vertexFileBytes
	{
		get
		{
			return (!(this.vertexFile != null)) ? null : this.vertexFile.bytes;
		}
	}

	// Token: 0x1700007C RID: 124
	// (get) Token: 0x0600036C RID: 876 RVA: 0x0001B89B File Offset: 0x00019A9B
	public bool skinningEnabled
	{
		get
		{
			return this._skinnedMeshRenderers != null && this._skinnedMeshRenderers.Length > 0;
		}
	}

	// Token: 0x0600036D RID: 877 RVA: 0x0001B8B6 File Offset: 0x00019AB6
	public MMD4MecanimBone GetRootBone()
	{
		return this._rootBone;
	}

	// Token: 0x0600036E RID: 878 RVA: 0x0001B8BE File Offset: 0x00019ABE
	public MMD4MecanimBone GetBone(int boneID)
	{
		if (this.boneList != null && boneID >= 0 && boneID < this.boneList.Length)
		{
			return this.boneList[boneID];
		}
		return null;
	}

	// Token: 0x0600036F RID: 879 RVA: 0x0001B8EA File Offset: 0x00019AEA
	private void Awake()
	{
		if (this.initializeOnAwake)
		{
			this.Initialize();
		}
	}

	// Token: 0x06000370 RID: 880 RVA: 0x0001B8FD File Offset: 0x00019AFD
	private void Start()
	{
		this.Initialize();
	}

	// Token: 0x06000371 RID: 881 RVA: 0x0001B908 File Offset: 0x00019B08
	private void Update()
	{
		if (!Application.isPlaying)
		{
			return;
		}
		this._Salvage();
		if (this.onUpdating != null)
		{
			this.onUpdating();
		}
		this._UpdateAnim();
		this._UpdateMorph();
		this._UpdateBone();
		this._UpdateIK();
		if (this.onUpdated != null)
		{
			this.onUpdated();
		}
	}

	// Token: 0x06000372 RID: 882 RVA: 0x0001B96C File Offset: 0x00019B6C
	private void _Salvage()
	{
		if (this._meshRenderers == null || this._skinnedMeshRenderers == null)
		{
			this._InitializeMesh();
		}
		if (this.modelFile != null)
		{
			if (this._modelData == null)
			{
				this._InitializeModelData();
			}
			if (this._modelData != null)
			{
				int num = (this.boneList == null) ? 0 : this.boneList.Length;
				int num2 = (this._modelData.boneDataList == null) ? 0 : this._modelData.boneDataList.Length;
				if (num != num2)
				{
					this._InitializeModel();
				}
				int num3 = (this.rigidBodyList == null) ? 0 : this.rigidBodyList.Length;
				int num4 = (this._modelData.rigidBodyDataList == null) ? 0 : this._modelData.rigidBodyDataList.Length;
				if (num3 != num4)
				{
					this._InitializeRigidBody();
				}
				if (this._morphBlendShapes == null && this._modelData.morphDataList != null && this._modelData.morphDataList.Length > 0 && this.blendShapesEnabled && this._IsBlendShapesAnything())
				{
					this._blendShapesEnabledCache = this.blendShapesEnabled;
					this._PrepareBlendShapes();
					this._InitializeBlendShapes();
				}
				if (this._animator == null || this._animMorphCategoryWeights == null)
				{
					this._InitializeAnimatoion();
				}
				if (this._animator != null && this._animator.avatar != null && this._animator.avatar.isValid && this._animator.avatar.isHuman && (this._leftArmBone == null || this._rightArmBone == null))
				{
					this._InitializePPHBones();
				}
				if (this.nextEdgeMaterial_Pass4 == null || this.nextEdgeMaterial_Pass4.shader == null || this.nextEdgeMaterial_Pass8 == null || this.nextEdgeMaterial_Pass8.shader == null)
				{
					this._InitializeNEXTMaterial();
				}
			}
		}
	}

	// Token: 0x06000373 RID: 883 RVA: 0x0001BBA4 File Offset: 0x00019DA4
	private void LateUpdate()
	{
		this._UpdatedDeffered();
		this._UpdatedNEXTEdge();
		if (!Application.isPlaying)
		{
			this._UpdateAmbientPreview();
		}
		if (!Application.isPlaying)
		{
			return;
		}
		if (this.onLateUpdating != null)
		{
			this.onLateUpdating();
		}
		this._LateUpdateBone();
		this._LateUpdateIK();
		this._UploadMeshMaterial();
		if (this.onLateUpdated != null)
		{
			this.onLateUpdated();
		}
	}

	// Token: 0x06000374 RID: 884 RVA: 0x00002973 File Offset: 0x00000B73
	private void OnRenderObject()
	{
	}

	// Token: 0x06000375 RID: 885 RVA: 0x0001BC18 File Offset: 0x00019E18
	private void OnDestroy()
	{
		this._DestroyDeferredMaterial();
		this._DestroyNEXTMaterial();
		if (this.ikList != null)
		{
			for (int i = 0; i < this.ikList.Length; i++)
			{
				if (this.ikList[i] != null)
				{
					this.ikList[i].Destroy();
				}
			}
			this.ikList = null;
		}
		this._sortedBoneList = null;
		if (this.boneList != null)
		{
			for (int j = 0; j < this.boneList.Length; j++)
			{
				if (this.boneList[j] != null)
				{
					this.boneList[j].Destroy();
				}
			}
			this.boneList = null;
		}
		if (this._bulletPhysicsMMDModel != null && !this._bulletPhysicsMMDModel.isExpired)
		{
			MMD4MecanimBulletPhysics instance = MMD4MecanimBulletPhysics.instance;
			if (instance != null)
			{
				instance.DestroyMMDModel(this._bulletPhysicsMMDModel);
			}
		}
		this._bulletPhysicsMMDModel = null;
	}

	// Token: 0x06000376 RID: 886 RVA: 0x0001BD08 File Offset: 0x00019F08
	public void Initialize()
	{
		if (!Application.isPlaying)
		{
			this.InitializeOnEditor();
			return;
		}
		if (this == null)
		{
			return;
		}
		if (this._initialized)
		{
			return;
		}
		this._initialized = true;
		this._blendShapesEnabledCache = this.blendShapesEnabled;
		this._InitializeMesh();
		this._InitializeModel();
		this._InitializeRigidBody();
		this._PrepareBlendShapes();
		this._InitializeBlendShapes();
		this._InitializeAnimatoion();
		this._InitializePhysicsEngine();
		this._InitializePPHBones();
		this._InitializeDeferredMesh();
		this._InitializeNEXTEdgeMesh();
		this._InitializeGlobalAmbient();
		this._InitializeIK();
	}

	// Token: 0x06000377 RID: 887 RVA: 0x0001BD9C File Offset: 0x00019F9C
	public AudioSource GetAudioSource()
	{
		if (this.audioSource == null)
		{
			this.audioSource = base.gameObject.GetComponent<AudioSource>();
			if (this.audioSource == null)
			{
				this.audioSource = base.gameObject.AddComponent<AudioSource>();
			}
		}
		return this.audioSource;
	}

	// Token: 0x06000378 RID: 888 RVA: 0x0001BDF4 File Offset: 0x00019FF4
	public void InitializeOnEditor()
	{
		if (this == null)
		{
			return;
		}
		if (this._modelData == null)
		{
			this._initialized = false;
		}
		if (this._modelData == null && this.modelFile == null)
		{
			return;
		}
		if (this._modelData == null && !this._InitializeModelData())
		{
			return;
		}
		if (this._modelData != null && this._modelData.boneDataList != null && (this.boneList == null || this.boneList.Length != this._modelData.boneDataList.Length))
		{
			this._initialized = false;
		}
		if (this._initialized)
		{
			return;
		}
		this._initialized = true;
		this._blendShapesEnabledCache = this.blendShapesEnabled;
		this._InitializeMesh();
		this._InitializeModel();
		this._InitializeRigidBody();
		this._PrepareBlendShapes();
		this._InitializeBlendShapes();
		this._InitializeAnimatoion();
		this._InitializeDeferredMaterial();
		this._InitializeNEXTMaterial();
		this._InitializeIK();
	}

	// Token: 0x06000379 RID: 889 RVA: 0x0001BEF0 File Offset: 0x0001A0F0
	private void _InitializeMesh()
	{
		if (this._meshRenderers != null)
		{
			for (int num = 0; num != this._meshRenderers.Length; num++)
			{
				if (this._meshRenderers[num] == null)
				{
					this._meshRenderers = null;
					break;
				}
			}
		}
		if (this._skinnedMeshRenderers != null)
		{
			for (int num2 = 0; num2 != this._skinnedMeshRenderers.Length; num2++)
			{
				if (this._skinnedMeshRenderers[num2] == null)
				{
					this._skinnedMeshRenderers = null;
					break;
				}
			}
		}
		if (this._meshRenderers == null || this._meshRenderers.Length == 0)
		{
			this._meshRenderers = MMD4MecanimCommon.GetMeshRenderers(base.gameObject);
			if (this._meshRenderers == null)
			{
				this._meshRenderers = new MeshRenderer[0];
			}
		}
		if (this._skinnedMeshRenderers == null || this._skinnedMeshRenderers.Length == 0)
		{
			this._skinnedMeshRenderers = MMD4MecanimCommon.GetSkinnedMeshRenderers(base.gameObject);
			if (this._skinnedMeshRenderers == null)
			{
				this._skinnedMeshRenderers = new SkinnedMeshRenderer[0];
			}
			if (this._skinnedMeshRenderers != null)
			{
				for (int num3 = 0; num3 != this._skinnedMeshRenderers.Length; num3++)
				{
					if (this._skinnedMeshRenderers[num3].updateWhenOffscreen != this.updateWhenOffscreen)
					{
						this._skinnedMeshRenderers[num3].updateWhenOffscreen = this.updateWhenOffscreen;
					}
				}
			}
		}
		if (this.defaultMesh == null && this._skinnedMeshRenderers != null && this._skinnedMeshRenderers.Length != 0)
		{
			this.defaultMesh = this._skinnedMeshRenderers[0].sharedMesh;
		}
		if (this.defaultMesh == null && this._meshRenderers != null && this._meshRenderers.Length != 0)
		{
			MeshFilter component = base.gameObject.GetComponent<MeshFilter>();
			if (component != null)
			{
				this.defaultMesh = component.sharedMesh;
			}
		}
	}

	// Token: 0x0600037A RID: 890 RVA: 0x0001C0DC File Offset: 0x0001A2DC
	private void _PrepareBlendShapes()
	{
		if (this._skinnedMeshRenderers != null)
		{
			for (int i = 0; i < this._skinnedMeshRenderers.Length; i++)
			{
				SkinnedMeshRenderer skinnedMeshRenderer = this._skinnedMeshRenderers[i];
				if (skinnedMeshRenderer != null)
				{
					Mesh sharedMesh = skinnedMeshRenderer.sharedMesh;
					if (sharedMesh != null)
					{
						for (int j = 0; j < sharedMesh.blendShapeCount; j++)
						{
							if (Application.isPlaying)
							{
								skinnedMeshRenderer.SetBlendShapeWeight(j, 0f);
							}
							else if (skinnedMeshRenderer.GetBlendShapeWeight(j) != 0f)
							{
								skinnedMeshRenderer.SetBlendShapeWeight(j, 0f);
							}
						}
					}
				}
			}
		}
	}

	// Token: 0x0600037B RID: 891 RVA: 0x0001C184 File Offset: 0x0001A384
	private bool _IsBlendShapesAnything()
	{
		if (this._skinnedMeshRenderers != null)
		{
			for (int i = 0; i < this._skinnedMeshRenderers.Length; i++)
			{
				SkinnedMeshRenderer skinnedMeshRenderer = this._skinnedMeshRenderers[i];
				if (skinnedMeshRenderer != null)
				{
					Mesh sharedMesh = skinnedMeshRenderer.sharedMesh;
					if (sharedMesh != null && sharedMesh.blendShapeCount > 0)
					{
						return true;
					}
				}
			}
		}
		return false;
	}

	// Token: 0x0600037C RID: 892 RVA: 0x0001C1EC File Offset: 0x0001A3EC
	private void _InitializeBlendShapes()
	{
		if (this._blendShapesEnabledCache && this._skinnedMeshRenderers != null && this._modelData != null && this._modelData.morphDataList != null && this._modelData.morphDataList.Length > 0 && (this._morphBlendShapes == null || this._morphBlendShapes.Length != this._skinnedMeshRenderers.Length))
		{
			this._morphBlendShapes = null;
			if (this._IsBlendShapesAnything())
			{
				this._morphBlendShapes = new MMD4MecanimModel.MorphBlendShape[this._skinnedMeshRenderers.Length];
				for (int i = 0; i < this._skinnedMeshRenderers.Length; i++)
				{
					this._morphBlendShapes[i] = default(MMD4MecanimModel.MorphBlendShape);
					this._morphBlendShapes[i].blendShapeIndices = new int[this._modelData.morphDataList.Length];
					for (int j = 0; j < this._modelData.morphDataList.Length; j++)
					{
						this._morphBlendShapes[i].blendShapeIndices[j] = -1;
					}
					SkinnedMeshRenderer skinnedMeshRenderer = this._skinnedMeshRenderers[i];
					if (skinnedMeshRenderer.sharedMesh != null && skinnedMeshRenderer.sharedMesh.blendShapeCount > 0)
					{
						for (int k = 0; k < skinnedMeshRenderer.sharedMesh.blendShapeCount; k++)
						{
							string blendShapeName = skinnedMeshRenderer.sharedMesh.GetBlendShapeName(k);
							int num;
							if (MMD4MecanimCommon.IsID(blendShapeName))
							{
								num = MMD4MecanimCommon.ToInt(blendShapeName);
							}
							else
							{
								num = this._modelData.GetMorphDataIndex(blendShapeName, false);
							}
							if (num < this._modelData.morphDataList.Length)
							{
								this._morphBlendShapes[i].blendShapeIndices[num] = k;
							}
						}
					}
				}
			}
		}
	}

	// Token: 0x0600037D RID: 893 RVA: 0x0001C3BC File Offset: 0x0001A5BC
	private static void _PostfixRenderQueue(Material[] materials, bool postfixRenderQueue, bool renderQueueAfterSkybox)
	{
		if (Application.isPlaying && materials != null)
		{
			for (int i = 0; i < materials.Length; i++)
			{
				if (materials[i].shader != null && materials[i].shader.name != null && materials[i].shader.name.StartsWith("MMD4Mecanim") && postfixRenderQueue)
				{
					int num = (!renderQueueAfterSkybox) ? 2002 : 2502;
					materials[i].renderQueue = num + MMD4MecanimCommon.ToInt(materials[i].name);
				}
			}
		}
	}

	// Token: 0x0600037E RID: 894 RVA: 0x0001C464 File Offset: 0x0001A664
	private static void _SetupCloneMaterial(MMD4MecanimModel.CloneMaterial cloneMaterial, Material[] materials)
	{
		cloneMaterial.materials = materials;
		if (materials != null)
		{
			int num = materials.Length;
			cloneMaterial.materialData = new MMD4MecanimData.MorphMaterialData[num];
			cloneMaterial.backupMaterialData = new MMD4MecanimData.MorphMaterialData[num];
			cloneMaterial.updateMaterialData = new bool[num];
			for (int i = 0; i < num; i++)
			{
				if (materials[i] != null)
				{
					MMD4MecanimCommon.BackupMaterial(ref cloneMaterial.backupMaterialData[i], materials[i]);
					cloneMaterial.materialData[i] = cloneMaterial.backupMaterialData[i];
				}
			}
		}
	}

	// Token: 0x0600037F RID: 895 RVA: 0x0001C4FC File Offset: 0x0001A6FC
	public bool IsEnableMorphBlendShapes(int meshIndex)
	{
		if (this._morphBlendShapes == null)
		{
			return false;
		}
		if (meshIndex < 0 || meshIndex >= this._morphBlendShapes.Length)
		{
			return false;
		}
		if (this._morphBlendShapes[meshIndex].blendShapeIndices == null)
		{
			return false;
		}
		for (int num = 0; num != this._morphBlendShapes[meshIndex].blendShapeIndices.Length; num++)
		{
			int num2 = this._morphBlendShapes[meshIndex].blendShapeIndices[num];
			if (num2 != -1)
			{
				return true;
			}
		}
		return false;
	}

	// Token: 0x06000380 RID: 896 RVA: 0x0001C588 File Offset: 0x0001A788
	private bool _InitializeModelData()
	{
		if (this.modelFile == null)
		{
			Debug.LogWarning(base.gameObject.name + ":modelFile is nothing.");
			return false;
		}
		this._modelData = MMD4MecanimData.BuildModelData(this.modelFile);
		if (this._modelData == null)
		{
			Debug.LogError(base.gameObject.name + ":modelFile is unsupported format.");
			return false;
		}
		return true;
	}

	// Token: 0x06000381 RID: 897 RVA: 0x0001C5FC File Offset: 0x0001A7FC
	private void _InitializeModel()
	{
		if (this._modelData == null && !this._InitializeModelData())
		{
			return;
		}
		if (this._modelData.boneDataList != null && this._modelData.boneDataDictionary != null && (this.boneList == null || this.boneList.Length != this._modelData.boneDataList.Length))
		{
			this.boneList = new MMD4MecanimBone[this._modelData.boneDataList.Length];
			this._BindBone();
			for (int i = 0; i < this.boneList.Length; i++)
			{
				if (this.boneList[i] != null)
				{
					this.boneList[i].Bind();
				}
			}
			this._sortedBoneList = new MMD4MecanimBone[this.boneList.Length];
			for (int j = 0; j < this.boneList.Length; j++)
			{
				if (this.boneList[j] != null)
				{
					MMD4MecanimData.BoneData boneData = this.boneList[j].boneData;
					if (boneData != null)
					{
						int sortedBoneID = boneData.sortedBoneID;
						if (sortedBoneID >= 0 && sortedBoneID < this.boneList.Length)
						{
							this._sortedBoneList[sortedBoneID] = this.boneList[j];
						}
					}
				}
			}
		}
		if (this._modelData.ikDataList != null)
		{
			int num = this._modelData.ikDataList.Length;
			this.ikList = new MMD4MecanimModel.IK[num];
			for (int k = 0; k < num; k++)
			{
				this.ikList[k] = new MMD4MecanimModel.IK(this, k);
			}
		}
		if (this._modelData.morphDataList != null)
		{
			this.morphList = new MMD4MecanimModel.Morph[this._modelData.morphDataList.Length];
			for (int l = 0; l < this._modelData.morphDataList.Length; l++)
			{
				this.morphList[l] = new MMD4MecanimModel.Morph();
				this.morphList[l].morphData = this._modelData.morphDataList[l];
				string name = this.morphList[l].name;
				if (!string.IsNullOrEmpty(name) && name != null)
				{
					if (!(name == "LightUp"))
					{
						if (!(name == "LightOff"))
						{
							if (!(name == "LightBlink"))
							{
								if (name == "LightBS")
								{
									this.morphList[l].morphAutoLuminousType = MMD4MecanimData.MorphAutoLumninousType.LightBS;
								}
							}
							else
							{
								this.morphList[l].morphAutoLuminousType = MMD4MecanimData.MorphAutoLumninousType.LightBlink;
							}
						}
						else
						{
							this.morphList[l].morphAutoLuminousType = MMD4MecanimData.MorphAutoLumninousType.LightOff;
						}
					}
					else
					{
						this.morphList[l].morphAutoLuminousType = MMD4MecanimData.MorphAutoLumninousType.LightUp;
					}
				}
			}
		}
		this.morphAutoLuminous = new MMD4MecanimModel.MorphAutoLuminous();
	}

	// Token: 0x04000480 RID: 1152
	private Animator _animator;

	// Token: 0x04000481 RID: 1153
	private MMD4MecanimModel.Anim _playingAnim;

	// Token: 0x04000482 RID: 1154
	private float _prevDeltaTime;

	// Token: 0x04000483 RID: 1155
	private float[] _animMorphCategoryWeights;

	// Token: 0x04000484 RID: 1156
	private int _delayedAwakeFrame;

	// Token: 0x04000485 RID: 1157
	private bool _isDelayedAwake;

	// Token: 0x04000486 RID: 1158
	private MMD4MecanimBone _leftShoulderBone;

	// Token: 0x04000487 RID: 1159
	private MMD4MecanimBone _rightShoulderBone;

	// Token: 0x04000488 RID: 1160
	private MMD4MecanimBone _leftArmBone;

	// Token: 0x04000489 RID: 1161
	private MMD4MecanimBone _rightArmBone;

	// Token: 0x0400048A RID: 1162
	[NonSerialized]
	public MMD4MecanimIKTarget[] fullBodyIKTargetList;

	// Token: 0x0400048B RID: 1163
	[NonSerialized]
	public Transform fullBodyIKTargets;

	// Token: 0x0400048C RID: 1164
	[NonSerialized]
	public Transform[] fullBodyIKGroupList;

	// Token: 0x0400048D RID: 1165
	public const float NEXTEdgeScale = 0.05f;

	// Token: 0x0400048E RID: 1166
	public Material nextEdgeMaterial_Pass4;

	// Token: 0x0400048F RID: 1167
	public Material nextEdgeMaterial_Pass8;

	// Token: 0x04000490 RID: 1168
	public MMD4MecanimModel.NEXTEdgePass nextEdgePass;

	// Token: 0x04000491 RID: 1169
	public float nextEdgeSize = 1f;

	// Token: 0x04000492 RID: 1170
	public Color nextEdgeColor = new Color(0.4f, 1f, 1f, 1f);

	// Token: 0x04000493 RID: 1171
	private MeshRenderer[] _nextEdgeMeshRenderers;

	// Token: 0x04000494 RID: 1172
	private SkinnedMeshRenderer[] _nextEdgeSkinnedMeshRenderers;

	// Token: 0x04000495 RID: 1173
	private bool _nextEdgeVisibleCached;

	// Token: 0x04000496 RID: 1174
	private float _nextEdgeSizeCached;

	// Token: 0x04000497 RID: 1175
	private Color _nextEdgeColorCached;

	// Token: 0x04000498 RID: 1176
	public bool supportNEXTEdge;

	// Token: 0x04000499 RID: 1177
	private bool _notFoundShaderNEXTPass4;

	// Token: 0x0400049A RID: 1178
	private bool _notFoundShaderNEXTPass8;

	// Token: 0x0400049B RID: 1179
	public const int MaterialEdgeRenderQueue = 2001;

	// Token: 0x0400049C RID: 1180
	public const int MaterialBaseRenderQueue = 2002;

	// Token: 0x0400049D RID: 1181
	public const int MaterialEdgeRenderQueue_AfterSkybox = 2501;

	// Token: 0x0400049E RID: 1182
	public const int MaterialBaseRenderQueue_AfterSkybox = 2502;

	// Token: 0x0400049F RID: 1183
	public float importScale = 0.01f;

	// Token: 0x040004A0 RID: 1184
	public bool initializeOnAwake;

	// Token: 0x040004A1 RID: 1185
	public bool postfixRenderQueue = true;

	// Token: 0x040004A2 RID: 1186
	public bool renderQueueAfterSkybox;

	// Token: 0x040004A3 RID: 1187
	public bool updateWhenOffscreen = true;

	// Token: 0x040004A4 RID: 1188
	public bool animEnabled = true;

	// Token: 0x040004A5 RID: 1189
	public bool animSyncToAudio = true;

	// Token: 0x040004A6 RID: 1190
	public TextAsset modelFile;

	// Token: 0x040004A7 RID: 1191
	public TextAsset indexFile;

	// Token: 0x040004A8 RID: 1192
	public TextAsset vertexFile;

	// Token: 0x040004A9 RID: 1193
	public AudioSource audioSource;

	// Token: 0x040004AA RID: 1194
	public int animDelayedAwakeFrame = 1;

	// Token: 0x040004AB RID: 1195
	public bool boneInherenceEnabled;

	// Token: 0x040004AC RID: 1196
	public bool boneMorphEnabled;

	// Token: 0x040004AD RID: 1197
	public bool pphEnabled;

	// Token: 0x040004AE RID: 1198
	public bool pphEnabledNoAnimation;

	// Token: 0x040004AF RID: 1199
	public bool pphShoulderEnabled = true;

	// Token: 0x040004B0 RID: 1200
	public float pphShoulderFixRate = 0.7f;

	// Token: 0x040004B1 RID: 1201
	public bool ikEnabled;

	// Token: 0x040004B2 RID: 1202
	public bool fullBodyIKEnabled;

	// Token: 0x040004B3 RID: 1203
	public bool vertexMorphEnabled = true;

	// Token: 0x040004B4 RID: 1204
	public bool materialMorphEnabled = true;

	// Token: 0x040004B5 RID: 1205
	public bool blendShapesEnabled = true;

	// Token: 0x040004B6 RID: 1206
	public bool xdefEnabled;

	// Token: 0x040004B7 RID: 1207
	public bool xdefNormalEnabled;

	// Token: 0x040004B8 RID: 1208
	public bool xdefMobileEnabled;

	// Token: 0x040004B9 RID: 1209
	private bool _blendShapesEnabledCache;

	// Token: 0x040004BA RID: 1210
	private float _pphShoulderFixRateImmediately;

	// Token: 0x040004BB RID: 1211
	public float generatedColliderMargin = 0.01f;

	// Token: 0x040004BC RID: 1212
	[NonSerialized]
	public MMD4MecanimBone[] boneList;

	// Token: 0x040004BD RID: 1213
	[NonSerialized]
	public MMD4MecanimModel.IK[] ikList;

	// Token: 0x040004BE RID: 1214
	[NonSerialized]
	public MMD4MecanimModel.Morph[] morphList;

	// Token: 0x040004BF RID: 1215
	[NonSerialized]
	public MMD4MecanimModel.MorphAutoLuminous morphAutoLuminous;

	// Token: 0x040004C0 RID: 1216
	public MMD4MecanimModel.PhysicsEngine physicsEngine;

	// Token: 0x040004C1 RID: 1217
	private MMD4MecanimModel.PhysicsEngine _physicsEngineCached;

	// Token: 0x040004C2 RID: 1218
	public MMD4MecanimModel.BulletPhysics bulletPhysics;

	// Token: 0x040004C3 RID: 1219
	public MMD4MecanimModel.RigidBody[] rigidBodyList;

	// Token: 0x040004C4 RID: 1220
	public MMD4MecanimModel.Anim[] animList;

	// Token: 0x040004C5 RID: 1221
	private bool _initialized;

	// Token: 0x040004C6 RID: 1222
	private MMD4MecanimBone _rootBone;

	// Token: 0x040004C7 RID: 1223
	private MMD4MecanimBone[] _sortedBoneList;

	// Token: 0x040004C8 RID: 1224
	private List<MMD4MecanimBone> _processingBoneList;

	// Token: 0x040004C9 RID: 1225
	private MeshRenderer[] _meshRenderers;

	// Token: 0x040004CA RID: 1226
	private SkinnedMeshRenderer[] _skinnedMeshRenderers;

	// Token: 0x040004CB RID: 1227
	private MMD4MecanimModel.CloneMesh[] _cloneMeshes;

	// Token: 0x040004CC RID: 1228
	private MMD4MecanimModel.MorphBlendShape[] _morphBlendShapes;

	// Token: 0x040004CD RID: 1229
	private MMD4MecanimModel.CloneMaterial[] _cloneMaterials;

	// Token: 0x040004CE RID: 1230
	private bool _supportDeferred;

	// Token: 0x040004CF RID: 1231
	private Light _deferredLight;

	// Token: 0x040004D0 RID: 1232
	public MMD4MecanimData.ModelData _modelData;

	// Token: 0x040004D1 RID: 1233
	[HideInInspector]
	public MMD4MecanimModel.EditorViewPage editorViewPage;

	// Token: 0x040004D2 RID: 1234
	[HideInInspector]
	public byte editorViewMorphBits = 15;

	// Token: 0x040004D3 RID: 1235
	[HideInInspector]
	public bool editorViewRigidBodies;

	// Token: 0x040004D4 RID: 1236
	[HideInInspector]
	public MMD4MecanimModel.EditorViewMorphNameType editorViewMorphNameType;

	// Token: 0x040004D5 RID: 1237
	[NonSerialized]
	public Mesh defaultMesh;

	// Token: 0x040004D6 RID: 1238
	private MMD4MecanimBulletPhysics.MMDModel _bulletPhysicsMMDModel;

	// Token: 0x040004D7 RID: 1239
	public Action onUpdating;

	// Token: 0x040004D8 RID: 1240
	public Action onUpdated;

	// Token: 0x040004D9 RID: 1241
	public Action onLateUpdating;

	// Token: 0x040004DA RID: 1242
	public Action onLateUpdated;

	// Token: 0x02000091 RID: 145
	public class IK
	{
		// Token: 0x06000382 RID: 898 RVA: 0x0001C8D0 File Offset: 0x0001AAD0
		public IK(MMD4MecanimModel model, int ikID)
		{
			if (model == null || model.modelData == null || model.modelData.ikDataList == null || ikID >= model.modelData.ikDataList.Length)
			{
				Debug.LogError(string.Concat(new object[]
				{
					"model:",
					model != null,
					" modelData:",
					model != null && model.modelData != null,
					" ikDataList:",
					model != null && model.modelData != null && model.modelData.ikDataList != null,
					" ikID:",
					ikID,
					" Length:",
					(!(model != null) || model.modelData == null || model.modelData.ikDataList == null) ? 0 : model.modelData.ikDataList.Length
				}));
				return;
			}
			this._ikID = ikID;
			this._ikData = model.modelData.ikDataList[ikID];
			if (this._ikData != null)
			{
				this._destBone = model.GetBone(this._ikData.destBoneID);
				this._targetBone = model.GetBone(this._ikData.targetBoneID);
				if (this._ikData.ikLinkDataList != null)
				{
					this._ikLinkList = new MMD4MecanimModel.IK.IKLink[this._ikData.ikLinkDataList.Length];
					for (int i = 0; i < this._ikData.ikLinkDataList.Length; i++)
					{
						this._ikLinkList[i] = new MMD4MecanimModel.IK.IKLink();
						this._ikLinkList[i].ikLinkData = this._ikData.ikLinkDataList[i];
					}
				}
			}
		}

		// Token: 0x1700007D RID: 125
		// (get) Token: 0x06000383 RID: 899 RVA: 0x0001CAC8 File Offset: 0x0001ACC8
		public int ikID
		{
			get
			{
				return this._ikID;
			}
		}

		// Token: 0x1700007E RID: 126
		// (get) Token: 0x06000384 RID: 900 RVA: 0x0001CAD0 File Offset: 0x0001ACD0
		public MMD4MecanimData.IKData ikData
		{
			get
			{
				return this._ikData;
			}
		}

		// Token: 0x1700007F RID: 127
		// (get) Token: 0x06000385 RID: 901 RVA: 0x0001CAD8 File Offset: 0x0001ACD8
		public MMD4MecanimBone destBone
		{
			get
			{
				return this._destBone;
			}
		}

		// Token: 0x17000080 RID: 128
		// (get) Token: 0x06000386 RID: 902 RVA: 0x0001CAE0 File Offset: 0x0001ACE0
		public MMD4MecanimBone targetBone
		{
			get
			{
				return this._targetBone;
			}
		}

		// Token: 0x17000081 RID: 129
		// (get) Token: 0x06000387 RID: 903 RVA: 0x0001CAE8 File Offset: 0x0001ACE8
		public MMD4MecanimModel.IK.IKLink[] ikLinkList
		{
			get
			{
				return this._ikLinkList;
			}
		}

		// Token: 0x17000082 RID: 130
		// (get) Token: 0x06000388 RID: 904 RVA: 0x0001CAF0 File Offset: 0x0001ACF0
		// (set) Token: 0x06000389 RID: 905 RVA: 0x0001CB10 File Offset: 0x0001AD10
		public bool ikEnabled
		{
			get
			{
				return this._destBone != null && this._destBone.ikEnabled;
			}
			set
			{
				if (this._destBone != null)
				{
					this._destBone.ikEnabled = value;
				}
			}
		}

		// Token: 0x17000083 RID: 131
		// (get) Token: 0x0600038A RID: 906 RVA: 0x0001CB2F File Offset: 0x0001AD2F
		// (set) Token: 0x0600038B RID: 907 RVA: 0x0001CB53 File Offset: 0x0001AD53
		public float ikWeight
		{
			get
			{
				if (this._destBone != null)
				{
					return this._destBone.ikWeight;
				}
				return 0f;
			}
			set
			{
				if (this._destBone != null)
				{
					this._destBone.ikWeight = value;
				}
			}
		}

		// Token: 0x0600038C RID: 908 RVA: 0x0001CB72 File Offset: 0x0001AD72
		public void Destroy()
		{
			this._ikData = null;
			this._destBone = null;
			this._targetBone = null;
			this._ikLinkList = null;
		}

		// Token: 0x040004DB RID: 1243
		private int _ikID;

		// Token: 0x040004DC RID: 1244
		private MMD4MecanimData.IKData _ikData;

		// Token: 0x040004DD RID: 1245
		private MMD4MecanimBone _destBone;

		// Token: 0x040004DE RID: 1246
		private MMD4MecanimBone _targetBone;

		// Token: 0x040004DF RID: 1247
		private MMD4MecanimModel.IK.IKLink[] _ikLinkList;

		// Token: 0x02000092 RID: 146
		public class IKLink
		{
			// Token: 0x040004E0 RID: 1248
			public MMD4MecanimData.IKLinkData ikLinkData;

			// Token: 0x040004E1 RID: 1249
			public MMD4MecanimBone bone;
		}
	}

	// Token: 0x02000093 RID: 147
	public enum NEXTEdgePass
	{
		// Token: 0x040004E3 RID: 1251
		Pass4,
		// Token: 0x040004E4 RID: 1252
		Pass8
	}

	// Token: 0x02000094 RID: 148
	public enum PhysicsEngine
	{
		// Token: 0x040004E6 RID: 1254
		None,
		// Token: 0x040004E7 RID: 1255
		BulletPhysics
	}

	// Token: 0x02000095 RID: 149
	public class Morph : MMD4MecanimAnim.IMorph
	{
		// Token: 0x17000086 RID: 134
		// (get) Token: 0x0600038F RID: 911 RVA: 0x0001CB90 File Offset: 0x0001AD90
		public MMD4MecanimData.MorphType morphType
		{
			get
			{
				if (this.morphData != null)
				{
					return this.morphData.morphType;
				}
				return MMD4MecanimData.MorphType.Group;
			}
		}

		// Token: 0x17000087 RID: 135
		// (get) Token: 0x06000390 RID: 912 RVA: 0x0001CBAA File Offset: 0x0001ADAA
		public MMD4MecanimData.MorphCategory morphCategory
		{
			get
			{
				if (this.morphData != null)
				{
					return this.morphData.morphCategory;
				}
				return MMD4MecanimData.MorphCategory.Base;
			}
		}

		// Token: 0x17000088 RID: 136
		// (get) Token: 0x06000391 RID: 913 RVA: 0x0001CBC4 File Offset: 0x0001ADC4
		public string name
		{
			get
			{
				if (this.morphData != null)
				{
					return this.morphData.nameJp;
				}
				return null;
			}
		}

		// Token: 0x17000089 RID: 137
		// (get) Token: 0x06000392 RID: 914 RVA: 0x0001CBDE File Offset: 0x0001ADDE
		public string translatedName
		{
			get
			{
				if (this.morphData != null)
				{
					return this.morphData.translatedName;
				}
				return null;
			}
		}

		// Token: 0x17000084 RID: 132
		// (get) Token: 0x06000393 RID: 915 RVA: 0x0001CBF8 File Offset: 0x0001ADF8
		string MMD4MecanimAnim.IMorph.name
		{
			get
			{
				return this.name;
			}
		}

		// Token: 0x17000085 RID: 133
		// (get) Token: 0x06000394 RID: 916 RVA: 0x0001CC00 File Offset: 0x0001AE00
		// (set) Token: 0x06000395 RID: 917 RVA: 0x0001CC08 File Offset: 0x0001AE08
		float MMD4MecanimAnim.IMorph.weight
		{
			get
			{
				return this.weight;
			}
			set
			{
				this.weight = value;
			}
		}

		// Token: 0x040004E8 RID: 1256
		public float weight;

		// Token: 0x040004E9 RID: 1257
		public float weight2;

		// Token: 0x040004EA RID: 1258
		public float _animWeight;

		// Token: 0x040004EB RID: 1259
		public float _appendWeight;

		// Token: 0x040004EC RID: 1260
		public float _updateWeight;

		// Token: 0x040004ED RID: 1261
		public float _updatedWeight;

		// Token: 0x040004EE RID: 1262
		public MMD4MecanimData.MorphData morphData;

		// Token: 0x040004EF RID: 1263
		public MMD4MecanimData.MorphAutoLumninousType morphAutoLuminousType;
	}

	// Token: 0x02000096 RID: 150
	public class MorphAutoLuminous
	{
		// Token: 0x040004F0 RID: 1264
		public float lightUp;

		// Token: 0x040004F1 RID: 1265
		public float lightOff;

		// Token: 0x040004F2 RID: 1266
		public float lightBlink;

		// Token: 0x040004F3 RID: 1267
		public float lightBS;

		// Token: 0x040004F4 RID: 1268
		public bool updated;
	}

	// Token: 0x02000097 RID: 151
	[Serializable]
	public class RigidBody
	{
		// Token: 0x040004F5 RID: 1269
		[NonSerialized]
		public MMD4MecanimData.RigidBodyData rigidBodyData;

		// Token: 0x040004F6 RID: 1270
		public bool freezed = true;

		// Token: 0x040004F7 RID: 1271
		public int _freezedCached = -1;
	}

	// Token: 0x02000098 RID: 152
	[Serializable]
	public class Anim : MMD4MecanimAnim.Anim
	{
	}

	// Token: 0x02000099 RID: 153
	[Serializable]
	public class BulletPhysics
	{
		// Token: 0x040004F8 RID: 1272
		public bool joinLocalWorld = true;

		// Token: 0x040004F9 RID: 1273
		public bool useOriginalScale = true;

		// Token: 0x040004FA RID: 1274
		public bool useCustomResetTime;

		// Token: 0x040004FB RID: 1275
		public float resetMorphTime = 1.8f;

		// Token: 0x040004FC RID: 1276
		public float resetWaitTime = 1.2f;

		// Token: 0x040004FD RID: 1277
		public WorldProperty worldProperty;

		// Token: 0x040004FE RID: 1278
		public MMDModelProperty mmdModelProperty;
	}

	// Token: 0x0200009A RID: 154
	public class CloneMesh
	{
		// Token: 0x040004FF RID: 1279
		public SkinnedMeshRenderer skinnedMeshRenderer;

		// Token: 0x04000500 RID: 1280
		public Mesh mesh;

		// Token: 0x04000501 RID: 1281
		public Vector3[] vertices;

		// Token: 0x04000502 RID: 1282
		public Vector3[] normals;

		// Token: 0x04000503 RID: 1283
		public Matrix4x4[] bindposes;

		// Token: 0x04000504 RID: 1284
		public BoneWeight[] boneWeights;
	}

	// Token: 0x0200009B RID: 155
	public class CloneMaterial
	{
		// Token: 0x04000505 RID: 1285
		public Material[] materials;

		// Token: 0x04000506 RID: 1286
		public MMD4MecanimData.MorphMaterialData[] materialData;

		// Token: 0x04000507 RID: 1287
		public MMD4MecanimData.MorphMaterialData[] backupMaterialData;

		// Token: 0x04000508 RID: 1288
		public bool[] updateMaterialData;
	}

	// Token: 0x0200009C RID: 156
	private struct MorphBlendShape
	{
		// Token: 0x04000509 RID: 1289
		public int[] blendShapeIndices;
	}

	// Token: 0x0200009D RID: 157
	public enum PPHType
	{
		// Token: 0x0400050B RID: 1291
		Shoulder
	}

	// Token: 0x0200009E RID: 158
	public enum EditorViewPage
	{
		// Token: 0x0400050D RID: 1293
		Model,
		// Token: 0x0400050E RID: 1294
		Bone,
		// Token: 0x0400050F RID: 1295
		IK,
		// Token: 0x04000510 RID: 1296
		Morph,
		// Token: 0x04000511 RID: 1297
		Anim,
		// Token: 0x04000512 RID: 1298
		Physics
	}

	// Token: 0x0200009F RID: 159
	public enum EditorViewMorphNameType
	{
		// Token: 0x04000514 RID: 1300
		Japanese,
		// Token: 0x04000515 RID: 1301
		English,
		// Token: 0x04000516 RID: 1302
		Translated
	}
}
